package com.chinasoft.mapper;

import com.chinasoft.pojo.Good;
import com.chinasoft.pojo.GoodCount;
import com.chinasoft.pojo.TeacherCount;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface GoodMapper {
    @Select("select * from good")
    List<Good> findAll();

    @Update("update good set count = #{count} where id = #{id}")
    int updateCount(@Param("id") Integer id,@Param("count") String count);
    @Select("SELECT  goodname, COALESCE(SUM(CONVERT(count, SIGNED)),0) AS total_type " +
            " FROM good " +
            " GROUP BY goodname ")
    List<GoodCount> findbytype();

    @Delete("delete from good where id = #{id}")
    int delete(Integer id);

    @Insert("insert into good (goodname,money,time,type ,context) " +
            " values (#{goodname},#{money},#{time},#{type},#{context})")
    int insert(Good good);

    @Update("update good set goodname = #{goodname},money= #{money}, " +
            " type= #{type},context= #{context} " +
            " where id = #{id}")
    int updateType(Good good);
}
